FROM ubuntu:16.04
LABEL maintainer="lizhen@example.com"
ENV REFRESHED_AT 2019-01-08

# 覆盖原文件
ADD sources.list /etc/apt/sources.list

RUN apt-get -qq update && apt-get -qq install redis-server redis-tools
EXPOSE 6379
ENTRYPOINT ["/usr/bin/redis-server" ]
CMD []

# 构建镜像
# sudo docker build -t lizhen/redis .
# 运行容器redis-demo
# sudo docker run -d -p 4300:6379 --name redis-demo lizhen/redis
# 运行容器test-tools
# sudo docker run -dit --name test-tools ubuntu:16.04 /bin/bash
# 连接容器test-tools
# docker exec -it test-tools /bin/bash
# 修改镜像源
# echo "deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted" > /etc/apt/sources.list
# echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted" >> /etc/apt/sources.list
# echo "deb http://mirrors.aliyun.com/ubuntu/ xenial universe" >> /etc/apt/sources.list
# echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe" >> /etc/apt/sources.list
# echo "deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse" >> /etc/apt/sources.list
# echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse" >> /etc/apt/sources.list
# echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse" >> /etc/apt/sources.list
# echo "deb http://archive.canonical.com/ubuntu xenial partner" >> /etc/apt/sources.list
# echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted" >> /etc/apt/sources.list
# echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe" >> /etc/apt/sources.list
# echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse" >> /etc/apt/sources.list
# echo "# deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties" >> /etc/apt/sources.list
# echo "# deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties" >> /etc/apt/sources.list
# echo "# deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties" >> /etc/apt/sources.list
# echo "# deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties" >> /etc/apt/sources.list
# echo "# deb-src http://archive.canonical.com/ubuntu xenial partner" >> /etc/apt/sources.list
# echo "# deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties" >> /etc/apt/sources.list
# test-tools安装redis-tools
# sudo apt-get update && sudo apt-get -y install redis-tools
# 使用宿主机ip测试redis-demo
# redis-cli -h 192.168.99.100 -p 4300
# 退出redis-tools
# exit
# 查看redis-demo的ip
# sudo docker inspect -f '{{ .NetworkSettings.IPAddress }}' redis-demo
# 连接容器test-tools
# docker exec -it test-tools /bin/bash
# 使用redis-demo的ip测试redis-demo
# redis-cli -h 172.17.0.4 -p 6379
# 停止并移除容器redis-demo
# docker stop redis-demo
# docker rm redis-demo
# 创建新的容器redis-demo
# docker run -d --name redis-demo lizhen/redis
# 停止并移除容器webapp-demo
# docker stop webapp-demo
# docker rm webapp-demo
# 挂载目录到所有的virtualbox虚拟机上并重启
# \\?\H:\Source —> H/Source
# 运行新的容器webapp-demo，连接容器redis-demo
# docker run -p 4200:4567 --name webapp-demo --link redis-demo:redis-demo-db -dit -v $PWD/webapp:/opt/webapp lizhen/sinatra /bin/bash
# 容器webapp-demo中运行程序webapp2
# nohup /opt/webapp/bin/webapp2 &
# 退出webapp-demo
# exit
# 连接容器test-tools
# docker exec -it test-tools /bin/bash
# curl测试webapp-demo
# curl -i -H 'Accept: application/json' -d 'name=Foo&status=Bar' http://192.168.99.100:4200/json
# curl -i http://192.168.99.100:4200/json